﻿using System;
using System.Windows.Forms;
using System.IO;

namespace Greg.XmlEditor.Presentation.Views
{
	public partial class BrowserWindow : Form
	{
		private readonly string fileName;

		public BrowserWindow(string fileName)
		{
			this.fileName = fileName;
			this.InitializeComponent();
			this.browser.Navigate(fileName);
			this.source.Text = File.ReadAllText(fileName);
		}

		private void OnClosing(object sender, FormClosingEventArgs e)
		{
			try
			{
				if (File.Exists(fileName))
					File.Delete(fileName);
			}
			catch
			{
			}
		}

		private void OnCloseClick(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}
